package rolesystem.middle.utilityclasses;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;

import rolesystem.middle.parameters.DefaultParametersGUI;

public class Utils
{
	
	public static ArrayList<Integer> arraytoIntegerArrayList(int[] carrierArray)
	{
		Integer[] carrierArrayI= new Integer[carrierArray.length];
		
		for(int i=0;i<carrierArray.length;i++)
			carrierArrayI[i]=new Integer(carrierArray[i]);
		
		return new ArrayList<Integer>(Arrays.asList(carrierArrayI));	
	}
	
	public static Color getColorbyIndex(final int color_index)
	{
		if(color_index<DefaultParametersGUI.KNOWN_COLOR_ARRAY.length)
			return DefaultParametersGUI.KNOWN_COLOR_ARRAY[color_index];
		else
			return new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255));
	}
	
	public static PositionSq calcDirection(PositionSq position, PositionSq goal_position)
	{
		PositionSq distance=PositionSq.diff(goal_position, position);
		
		PositionSq direction= new PositionSq(0,0);
		
		if(distance.getX()!=0)
			direction.x = distance.x/ Math.abs(distance.x);
		
		if(distance.getY()!=0)
			direction.y = distance.y/ Math.abs(distance.y);
		
		return direction;
	}
	
}
